Skip to content

[Testing] Harden Appium force-close process lifecycle - #40835

Merged
kubaflo merged 3 commits into
mainfrom
simonrozsival-harden-appium-force-close
Nov 30, 2026
Merged

kubaflo merged 3 commits into
mainfrom
simonrozsival-harden-appium-force-close

Conversation

@simonrozsival

@simonrozsival simonrozsival commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: dd3381d1d3b331803f9379f5798c38356ff5383c

Dimension Assessment Rationale
Change confidence 9/10 ↑ TestUtils.UnitTests passed 73 tests with 1 unrelated Windows-only skip; the 12 focused lifecycle tests passed.
↑ An exact-source Linux .NET 11 probe confirmed KillOnParentExit, bounded timeout, and removal of a live descendant within 10 seconds.
↓ Actual simctl, ADB, pkill, and taskkill executions, Windows-native process-tree behavior, and a device-level Appium suite were not exercised.
Diagnosis confidence 9.5/10 ↑ The fixture reproduces a zero-exit command whose descendant keeps redirected pipes open, and Succeeded now fails unless the command exits zero and every drain/process cleanup succeeds.
↑ The original force-close paths returned success despite timeout or nonzero exit and did not wait for redirected streams or termination.
Evidence fit 9.5/10 ↑ Heavy dual-stream output, exit 23, timeout/tree cleanup, invalid simctl/ADB results, clean zero exit, and incomplete-drain propagation are deterministically covered.
↓ No real simulator, emulator, or Windows host execution confirms platform-tool integration.

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Target Branch

This PR is for Initial base
New features, API changes, or .NET 12 work (including .NET 12 fixes) main
.NET 11 servicing fixes net11, for review
Older servicing, release integration, infrastructure, or documentation The branch designated for that work

For .NET 11 fixes, only a maintainer retargets the approved PR to the active
inflight lane and merges it after CI validates that final base. Do not merge
individual fixes directly into net11; agents must not retarget or merge.

Description of Change

Harden Appium force-close and recovery process execution without changing fixture launch behavior:

  • Use exact ProcessStartInfo.ArgumentList transport for RunAdb, simctl termination, ADB force-stop, pkill, and taskkill.
  • Concurrently drain and discard stdout/stderr, preserving the existing 15-second RunAdb and 10-second force-close waits; terminate the whole process tree and wait boundedly after timeout; set KillOnParentExit only on Windows and Linux.
  • Keep RunAdb best-effort, but fail force-close closed for start, timeout, termination, drain, and nonzero-exit failures instead of returning success.
  • Add a self-contained Appium lifecycle fixture and deterministic tests for 2 MiB on both output streams, exit 23, timeout/tree cleanup, exact argv, incomplete drains, clean zero exit, invalid simctl/ADB results, and propagation of a zero-exit drain failure through force-close.

This intentionally ports only the process-lifecycle portion previously bundled into #39621 and reverted with the broader direct-launch work. It does not reintroduce direct fixture launch, startup/session changes, navigation, or test-selection behavior, and it does not modify ShellHelper or ToolRunner.

Validation

  • dotnet format src/TestUtils/src/UITest.Appium/UITest.Appium.csproj --no-restore --include src/TestUtils/src/UITest.Appium/Actions/AppiumLifecycleActions.cs src/TestUtils/src/UITest.Appium/AppiumProcessRunner.cs src/TestUtils/src/UITest.Appium/Properties/AssemblyInfo.cs --exclude-diagnostics CA1822 --verbosity minimal — passed.
  • dotnet format src/TestUtils/tests/TestUtils.UnitTests/TestUtils.UnitTests.csproj --no-restore --include src/TestUtils/tests/TestUtils.UnitTests/Program.cs src/TestUtils/tests/TestUtils.UnitTests/AppiumLifecycleProcessFixture.cs src/TestUtils/tests/TestUtils.UnitTests/AppiumLifecycleProcessTests.cs --exclude-diagnostics CA1822 --verbosity minimal — passed.
  • dotnet build src/TestUtils/tests/TestUtils.UnitTests/TestUtils.UnitTests.csproj --no-restore --nologo — passed with 0 warnings and 0 errors.
  • dotnet test src/TestUtils/tests/TestUtils.UnitTests/TestUtils.UnitTests.csproj --no-build --no-restore --nologo — passed: 73 succeeded, 1 Windows-only test skipped, 0 failed on macOS arm64.
  • dotnet test src/TestUtils/tests/TestUtils.UnitTests/TestUtils.UnitTests.csproj --no-build --no-restore --filter 'FullyQualifiedName~AppiumLifecycleProcessTests' --nologo — passed: 12/12 focused lifecycle tests.
  • Focused Linux .NET 11.0.100 container probe using the exact AppiumProcessRunner.cs — passed: KillOnParentExit was enabled, the timed-out root failed, and its live child exited within 10 seconds.

Platform gaps: local execution covered macOS arm64 and a Linux aarch64 container. Actual simctl, ADB, pkill, and taskkill commands, Windows-native process-tree/KillOnParentExit behavior, and device-level Appium UI runs were not exercised. The earlier UI-test dispatch did not queue maui-pr-uitests.

Issues Fixed

N/A — test infrastructure hardening; no issue was provided.

Let AI finish this PR

  • Let the MAUI agent address review feedback and fix remaining issues on this PR. Maintainers still decide whether it is merged. For PRs from forks, keep "Allow edits by maintainers" on so the agent can push to your branch; otherwise it opens a follow-up PR that keeps your commits.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

This comment has been minimized.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.
Some pipeline(s) encountered errors during trigger evaluation.

@kubaflo

This comment has been minimized.

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expert Review — 1 finding

Reviewed commit 2ed2380.

See inline comments for details.

@github-actions

This comment has been minimized.

simonrozsival and others added 2 commits November 30, 2026 16:21
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@simonrozsival
simonrozsival marked this pull request as ready for review November 30, 2026 15:30
Copilot AI balanced review requested due to automatic review settings November 30, 2026 15:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

AppiumProcessRunner leaves accessed output and error readers undisposed, leaking two pipe handles per RunAdb or force-close invocation until garbage collection.

1 open issue
What changed in this PR

This PR hardens Appium force-close and recovery commands in MAUI’s test infrastructure. It isolates the process-lifecycle work from #39621 without restoring direct fixture launch or changing navigation and session behavior.

Changes:

  • Adds a shared process runner with concurrent output draining, bounded waits, process-tree termination, and structured failure results.
  • Routes force-close and ADB recovery through the runner, reporting force-close failures while keeping recovery best-effort.
  • Adds a standalone process fixture and lifecycle tests covering output volume, exits, timeouts, argument handling, and incomplete drains.
File Description
src/​TestUtils/​tests/​TestUtils.UnitTests/​Program.cs Dispatches process-fixture modes before starting the test runner.
src/​TestUtils/​tests/​TestUtils.UnitTests/​AppiumLifecycleProcessTests.cs Tests process lifecycle and force-close result handling.
src/​TestUtils/​tests/​TestUtils.UnitTests/​AppiumLifecycleProcessFixture.cs Provides controlled output, exit, and child-process scenarios.
src/​TestUtils/​src/​UITest.Appium/​Properties/​AssemblyInfo.cs Exposes internal helpers to the unit-test assembly.
src/​TestUtils/​src/​UITest.Appium/​AppiumProcessRunner.cs Centralizes process execution, draining, cleanup, and failure reporting.
src/​TestUtils/​src/​UITest.Appium/​Actions/​AppiumLifecycleActions.cs Integrates the runner into platform force-close and ADB recovery.

Review effort: Balanced

@kubaflo

This comment has been minimized.

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expert Review — 1 finding

Reviewed commit dd3381d.

See inline comments for details.

@github-actions

Copy link
Copy Markdown
Contributor

Selected Tests

@kubaflo — AI-selected UI tests and device tests (GPT-6.2 Sol + MAI Code 2) for commit dd3381d1.

Result NOT QUEUED Platforms Android, iOS, MacCatalyst, Windows Tests all UI, 0 device Commit dd3381d1


🧪 Test selection — click to expand
Suite Result Selected Build
UI tests ❌ not queued all 77 categories —
Device tests ➖ nothing to run none —
🧪 UI tests — the full suite on every platform

❌ Could not queue maui-pr-uitests: Azure Pipelines did not start maui-pr-uitests for the dispatch branch run-tests/pr40835-46458761861 within 10 minutes. Comment /review run-tests again, or use /azp run maui-pr-uitests for the full suite.

GPT-6.2 Sol: Run the full UI suite on all four platforms because the PR changes shared Appium force-close and crash recovery.
MAI Code 2: Shared Appium process-lifecycle infrastructure changes across UI test force-close and recovery paths; runs the full UI suite on all platforms.

🧪 Running — 77 categories on Android, iOS, MacCatalyst, Windows

The complete maui-pr-uitests suite runs on every platform (same as /azp run).

🧪 Device tests — nothing to run

ℹ️ The AI found no changes relevant to device tests, so no maui-pr-devicetests run was queued.

GPT-6.2 Sol: No device tests are needed for this Appium-only change.
MAI Code 2: No device suites are affected; the change is confined to Appium UI-test process infrastructure and its unit tests.

🧪 Running — nothing

No device tests run for this PR.

⏭️ Skipped — what neither suite runs

Device tests — 105 categories, 4 platforms

Platforms not run: Android, iOS, MacCatalyst, Windows

Each skipped platform and project is listed as a maui-pr-devicetests (skipped) … status on this commit. Use /azp run maui-pr-devicetests for the full suite.

🤖 Why these tests — AI rationale (GPT-6.2 Sol + MAI Code 2)

UI tests

Each model chose independently; every test that runs was selected by at least one of them.

Platform GPT-6.2 Sol MAI Code 2
Android all categories all categories
iOS all categories all categories
MacCatalyst all categories all categories
Windows all categories all categories

GPT-6.2 Sol — Run the full UI suite on all four platforms because the PR changes shared Appium force-close and crash recovery.

  • AppiumLifecycleActions changes force-close and recovery on Android, iOS, Mac Catalyst, and Windows.
  • AppiumProcessRunner changes timeout and cleanup behavior across UI fixtures, so no control category is excluded.

MAI Code 2 — Shared Appium process-lifecycle infrastructure changes across UI test force-close and recovery paths; runs the full UI suite on all platforms.

  • UITest.Appium force-close and RunAdb execution is shared UI test infrastructure used across controls and platforms.
  • Process startup, timeout, termination, and output-drain behavior can affect UI test recovery on Android, iOS, MacCatalyst, and Windows.
  • No changed UI test category is present, and the infrastructure blast radius is broad enough to require a full run rather than selected control categories.

Device tests

Each model chose independently; every test that runs was selected by at least one of them.

Platform GPT-6.2 Sol MAI Code 2
Android — —
iOS — —
MacCatalyst — —
Windows — —

GPT-6.2 Sol — No device tests are needed for this Appium-only change.

  • The changed Appium actions and runner belong to the UI harness, not the Helix device-test harness.
  • The new lifecycle tests are host unit tests; device-test projects and shared device infrastructure are unchanged.

MAI Code 2 — No device suites are affected; the change is confined to Appium UI-test process infrastructure and its unit tests.

  • UITest.Appium is UI test infrastructure, not device-test application or handler code.
  • The remaining changes are unit-test fixtures/tests for that process runner, with no device-test category hints or device runtime behavior changes.

Generated by /review run-tests. A targeted run is a fast signal, not full-suite certification.

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/autopilot-running MAUI Autopilot loop is running; remove this label to stop it label Nov 30, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions Bot added the s/autopilot-fixing MAUI Autopilot: fixing review findings or failing tests (GPT-6.2 Sol vs MAI Code 2) label Nov 30, 2026
@kubaflo
kubaflo merged commit 3f63e09 into main Nov 30, 2026
10 of 12 checks passed
@kubaflo
kubaflo deleted the simonrozsival-harden-appium-force-close branch November 30, 2026 22:19
@github-actions github-actions Bot added the s/autopilot-retrying maui-expert-autopilot: retrying a step that failed once label Nov 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

MAUI Autopilot — Retrying

@kubaflo ❌ The fix round failed. The loop retries it once. Run.

Error
safe_outputs: ✗ Message 1 (push_to_pull_request_branch) failed: Branch simonrozsival-harden-appium-force-close no longer exists on origin (it may have been deleted), can't push to it.
safe_outputs: 1 safe output(s) failed:

@kubaflo kubaflo removed s/autopilot-running MAUI Autopilot loop is running; remove this label to stop it s/autopilot-fixing MAUI Autopilot: fixing review findings or failing tests (GPT-6.2 Sol vs MAI Code 2) s/autopilot-retrying maui-expert-autopilot: retrying a step that failed once labels Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants